import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/front/home' },
  {
    path: '/front',
    name: 'Front',
    component: () => import(/* webpackChunkName: "about" */ '../views/pages/front/Front.vue'),
    children: [
      {
        path: 'home',
        name:'Home',
        component:()=>import('../views/pages/front/HomePage.vue')
      },
      {
        path: 'cart',
        name:'Cart',
        component:()=>import('../views/pages/front/ShoppingCart.vue')
      },
      {
        path: 'about',
        name:'About',
        component:()=>import('../views/pages/front/About.vue')
      }
    ]
  },
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    //登录
	  path:'/login',
	  name:'login',
	  component: () => import(/* webpackChunkName: "about" */ '../views/pages/Login.vue')
  },
  {
    //注册
	  path:'/register',
	  name:'register',
	  component: () => import(/* webpackChunkName: "about" */ '../views/pages/Register.vue')
  },
  {
    //管理员
    path:'/managerMain',
    name:'managerMain',
    component: () => import('../views/pages/manager/managerMain.vue'),
    children: [
      { path: '/userAllInfo', name: 'userAllInfo', component: () => import('../views/pages/manager/user.vue')},
      { path:'/bookManage', name:'bookManage', component: () => import('../views/pages/manager/bookManage.vue')},
      { path:'/orderManage', name:'orderManage', component: () => import('../views/pages/manager/orderManage.vue')}
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
